﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing;

namespace frost
{
    class MenyText
    {
        private String text;
        private bool mouseHover = false;
        int x = 0;
        int y = 0;
        int w = 400;
        int h = 40;
        RectangleF rec;

        public MenyText(String t, int x, int y)
        {
            this.text = t;
            this.x = x;
            this.y = y;
            rec = new RectangleF((float)this.x, (float)this.y, (float)this.w, (float)this.h);
        }

        public void MouseHover(Form form, int x, int y)
        {
            if(rec.Contains(x,y))
            {
                if(this.mouseHover == false) form.Invalidate(Rectangle.Round(rec));
                this.mouseHover = true;
            }
            else
            {
                if (this.mouseHover == true) form.Invalidate(Rectangle.Round(rec));
                this.mouseHover = false;
            }
        }
        public bool mouseClicked(Form form, int x, int y)
        {
            if (rec.Contains(x, y))
                return true;

            return false;
        }

        public void Draw(Graphics g)
        {
            StringFormat stringFormat = new StringFormat();
            stringFormat.Alignment = StringAlignment.Center;

            if(mouseHover)
                g.DrawString(this.text, new Font("Doktor Terror", 24),
                    Brushes.Red, rec, stringFormat);
            else
                g.DrawString(this.text, new Font("Doktor Terror", 20),
                    Brushes.Red, rec, stringFormat);
        }
    }
}